package org.jvnet.hudson.client_demo;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Calendar;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;

public class UpdateJob {

	public static void main(String[] args) throws Exception {
		final String projectName = "MR_BL_DevOps"; 
		 
		 // JENKINS_URL/job/EJBModule/build?token=TOKEN_NAME
		PostMethod postMethod = new PostMethod("http://10.144.97.100:8080/jenkins/job/"+projectName+"/build?token="+projectName);
		//PostMethod postMethod = new PostMethod("http://10.144.97.100:8080/jenkins/job/"+projectName+"/config.xml");
		//postMethod.setRequestHeader("Content-type","application/xml; charset=UTF-8");
		//postMethod.setRequestBody(new FileInputStream(new File("C:\\Users\\Arthur\\Dropbox\\Arthur\\wsElegance\\client_demo\\src\\main\\java\\org\\jvnet\\hudson\\client_demo\\config2.xml")));
		
		HttpClient client = new HttpClient();
		int returnCode = client.executeMethod(postMethod);

		System.out.println( String.valueOf(returnCode) );

	}

}
